package com.lanlian.cayman.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.webkit.WebView;
import android.widget.TextView;

import com.lanlian.cayman.R;
import com.lanlian.commonlib.base.BaseActivity;
import com.lanlian.commonlib.bean.db.DBMessage;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/8/16 11:15
 *     desc   : 消息详情页面
 *     version: 1.0
 * </pre>
 */
public class MessageDetailActivity extends BaseActivity {

    private TextView mTvTitle;
    private TextView mTvTime;
    private WebView mWebView;

    private DBMessage mMessageInfo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_detail, true);
        initView();
        initData();
        if (mMessageInfo != null) {
            mTvTitle.setText(mMessageInfo.getTitle());
            mTvTime.setText(mMessageInfo.getPushTime());
            mWebView.loadDataWithBaseURL( null, mMessageInfo.getContent() , "text/html", "UTF-8", null );
        }
    }

    @Override
    protected void initView() {
        super.initView();
        setTitle("消息详情");
        mTvTitle = findViewById(R.id.tv_message_title);
        mTvTime = findViewById(R.id.tv_time);
        mWebView = findViewById(R.id.web_view);
    }

    @Override
    protected void initData() {
        super.initData();
        mMessageInfo = (DBMessage) getIntent().getSerializableExtra("messageInfo");
    }

    @Override
    protected void onStop() {
        super.onStop();
        mWebView = null;
    }
}
